/**
 * <copyright>
 *
 * Copyright (c) 2011 Zeligsoft (2009) Limited
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   Zeligsoft (2009) Limited - Initial API and implementation
 *
 * </copyright>
 *
 */
package com.zeligsoft.omg.lwccm.deployment;

import org.eclipse.emf.ecore.EObject;
import org.omg.deployment.DeploymentPackage;
import org.omg.deployment.DeploymentPlan;

import com.google.common.base.Preconditions;

public enum DeploymentUtil {
	INSTANCE;
	
	public DeploymentPlan getDeploymentPlan(final EObject eObj) {
		Preconditions.checkNotNull(eObj);
		DeploymentPlan plan = null;
		EObject next = eObj;
		for(;next != null && plan == null; next = next.eContainer()) {
			if(DeploymentPackage.eINSTANCE.getDeploymentPlan().isInstance(next)) {
				plan = (DeploymentPlan) next;
			}
		}
		
		return plan;
		
	}
}
